package file;


import file.constant.SysConstant;
import file.listener.SearchBtnListener;
import file.model.FileModel;
import file.model.SearchModel;
import file.untils.FilePositionUntils;
import file.untils.FileUntils;

import javax.swing.*;
import javax.swing.tree.*;
import java.awt.*;
import java.util.List;

/**
 * 文件操作窗体
 * @Author: zou
 * @email: 704572528@qq.com
 */
public class FileForm {



    public static void main(String[] args) throws InterruptedException {
        // 开启窗体
        FileFrame fileFrame = openFrom();

        // 开启线程加载磁盘全部文件夹
        // scanFile(fileFrame);
    }




    /**
     * 开启线程加载磁盘
     * @param fileFrame
     * @throws InterruptedException
     */
   /* private static void scanFile(FileFrame fileFrame) throws InterruptedException {
        List<FileModel> rootModel = FileUntils.listDrive();
        if (rootModel != null) {

            for (FileModel model : rootModel) {
                Thread thread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        node = new DefaultMutableTreeNode(model.getFullName());
                        FileUntils.listRootFile(model,node);
                        topTree.add(node);
                        // leftTree = new JTree (topTree);
                    }
                } );
                thread.start();
                thread.join();
            }
            fileFrame.getLeftTree().removeAll();
            fileFrame.getLeftTree().add(new JTree(topTree));
            fileFrame.getLeftTree().updateUI();
            System.out.println("更新一下 Jtree");
            // fileFrame.setLeftTree(new JTree(topTree));
        }


    }*/


    /**
     * 窗体初始化
     */
    private static FileFrame  openFrom() {
        // 设置软件姓名
        FileFrame fileForm = new FileFrame(SysConstant.FORM_NAME);
        // 获取居中位置
        fileForm.setSize(FilePositionUntils.getCenter());
        fileForm.setLocationRelativeTo(null);
        fileForm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        fileForm.pack();
        fileForm.setVisible(true);
        return fileForm;
    }


}
